package com.example.hanchen.yongkanggy.utils;

import java.util.Random;

public class String16BitUtils {
    public static String generateRandomNumberAndLetters(int length) {
        if (length % 2 != 0) {
            throw new IllegalArgumentException("长度异常");
        }
        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);

        for (int i = 0; i < length / 2; i++) {
            int randomDigit = random.nextInt(10); // 生成一个0-9的随机数
            char randomChar = (char) (random.nextInt(26) + 'A'); // 生成一个'A'-'Z'的随机字母
            sb.append(randomDigit);
            sb.append(randomChar);
        }
        return sb.toString();
    }
}
